package studio.xiaoyun.core.parameter.criterion;

import java.util.Collection;

public final class Query {
	
	/**
	 * 逻辑与
	 * @param criterions 搜索条件
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion and(Criterion... criterions) {
		CriterionAnd criterion = new CriterionAnd(criterions);
		return criterion;
	}

	/**
	 * 两者之间。
	 * <p>lo <= propertyValue <= hi
	 * @param propertyName 属性名
	 * @param lo 较小的值
	 * @param hi 较大的值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion between(String propertyName, Object lo, Object hi) {
		CriterionBetween criterion = new CriterionBetween(propertyName,lo,hi);
		return criterion;
	}

	/**
	 * 等于
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion equals(String propertyName, Object value) {
		CriterionEquals criterion = new CriterionEquals(propertyName,value);
		return criterion;
	}

	/**
	 * 大于等于
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0  
	 */
	public static Criterion ge(String propertyName, Object value) {
		CriterionGe criterion = new CriterionGe(propertyName,value);
		return criterion;
	}

	/**
	 * 大于
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion gt(String propertyName, Object value) {
		CriterionGt criterion = new CriterionGt(propertyName,value);
		return criterion;
	}

	/**
	 * 范围查询
	 * @param propertyName  属性名
	 * @param values 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion in(String propertyName, Collection<?> values) {
		CriterionIn criterion = new CriterionIn(propertyName,values);
		return criterion;
	}

	/**
	 * 属性为null
	 * @param propertyName  属性名
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion isNULL(String propertyName) {
		CriterionIsNull criterion = new CriterionIsNull(propertyName);
		return criterion;
	}

	/**
	 * 小于等于
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion le(String propertyName, Object value) {
		CriterionLe criterion = new CriterionLe(propertyName,value);
		return criterion;
	}

	/**
	 * 模糊查询
	 * <br/>支持占位符‘%’、'_'
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion like(String propertyName, Object value) {
		CriterionLike criterion = new CriterionLike(propertyName,value);
		return criterion;
	}

	/**
	 * 小于
	 * @param propertyName  属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion lt(String propertyName, Object value) {
		CriterionLt criterion = new CriterionLt(propertyName,value);
		return criterion;
	}

	/**
	 * 不等于
	 * @param propertyName 属性名
	 * @param value 值
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion notEquals(String propertyName, Object value){
		CriterionNotEquals criterion = new CriterionNotEquals(propertyName,value);
		return criterion;
	}

	/**
	 * 逻辑或
	 * @param criterions Criterion实例
	 * @return Criterion实例
	 * @since 1.0.0
	 */
	public static Criterion or(Criterion... criterions) {
		CriterionOr criterion = new CriterionOr(criterions);
		return criterion;
	}
	
	private Query() {}

}
